//
//  FSLeftTabController_Second.m
//  WZSOA
//
//  Created by 刘沿 on 16/6/28.
//  Copyright © 2016年 刘沿. All rights reserved.
//

#import "FSLeftTabController_Second.h"
#import "FSCSCell.h"

@interface FSLeftTabController_Second ()
@property (nonatomic,strong) NSMutableArray *contentArray;

@end

@implementation FSLeftTabController_Second

static NSString * const reuseIdentifier = @"reuseIdentifier";

- (NSMutableArray *)contentArray{
    
    if (_contentArray == nil) {
        
        _contentArray = [NSMutableArray array];
    }
    
    return _contentArray;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    self.clearsSelectionOnViewWillAppear = NO;

    self.title = @"近期经办";
    
    self.tableView.backgroundColor = [UIColor colorWithRed:0/255.0 green:94/255.0 blue:219 /255.0 alpha:1];
     
}

- (void)viewDidLoad {
    [super viewDidLoad];
  
    self.navigationController.navigationBar.translucent = NO;
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"recentNotice" ofType:@"plist"];
    
    NSMutableArray *array = [NSMutableArray arrayWithContentsOfFile:path];
    self.contentArray = array;
    
    //默认选中第一行
    [self.tableView  selectRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone];
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath: indexPath];
    
    if (cell.selected) {
        cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:70/255.0 blue:163 /255.0 alpha:1];
    }
    
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.contentArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    FSCSCell* cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    
    if (cell == nil) {
        
        cell = [FSCSCell CSCell];
    }
    
    NSDictionary *dict = self.contentArray[indexPath.row];
    
    cell.dict = dict;
    
    cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:94/255.0 blue:219 /255.0 alpha:1];
    
    
    return cell;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 100;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:70/255.0 blue:163 /255.0 alpha:1];
    
    if (self.recentBlock) {
        
        self.recentBlock(indexPath.row);
    }

    if (indexPath.row == 0) {
        
        self.ColorBlock(cell);
    }
    
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:94/255.0 blue:219 /255.0 alpha:1];
    
}


@end












